<script>
export default {
  name: "MyAnimation3",
  data() {
    return {
      isShow: true,
    }
  }
}
</script>

<template>
  <div>
    <button @click="isShow=!isShow">显示/隐藏</button>
    <!--    使用多个元素需要用到transition group,并且每一个元素都需要有一个唯一的key值-->
    <transition-group name="hello" appear>
      <h2 v-show="isShow" :key="1">你好啊</h2>
      <h2 v-show="!isShow" :key="2">曾宇杰</h2>
    </transition-group>
  </div>
</template>

<style scoped>

h2 {
  background-color: orange;

}

.hello-enter-active, .hello-leave-active {
  transition: 0.5s linear;
}

.hello-enter, .hello-leave-to {
  transform: translateX(-100%);
}

.hello-enter-to, .hello-leave {
  transform: translateX(0);
}

</style>